import React, { useState, useEffect } from 'react';
import "antd/dist/antd.min.css";
import { Modal, Button } from "../../component/common";
import './index.scss';
import fetch from '../../util/fetch';
import { Scrollbars } from 'react-custom-scrollbars';
import { flatten } from '../../util/usefulJS';
import { getQueryVariable } from '../../util/public';
import { message, TreeSelect } from 'antd';

const { TreeNode } = TreeSelect

function SelectUser(props) {

    const [isVisiable, setIsVisiable] = useState(false)
    const [chooseList, setChooseList] = useState([])
    const [allList, setAllList] = useState(null)
    const [showList, setShowList] = useState([])
    const [chooseType, setChooseType] = useState(0) //0-学校;1-角色
    const [level, setLevel] = useState(0) //0-第一层、1-第二层、2、第三层
    const [idList, setIdList] = useState([])
    const [preList, setPreList] = useState([])
    const [allListById, setAllListById] = useState([])  //按角色列表
    const [checkStatus, setCheckStatus] = useState(0)   //全选状态
    const [selectShowList, setSelectShowList] = useState([]);   //名称归类List
    const [allData, setAllData] = useState([]);
    const [schoolList, setSchoolList] = useState([]);
    const [allNum, setAllNum] = useState(0);

    useEffect(() => {
        if (!allList) return
        let arr = [], rArr = []
        //学校（全部高中、全部初中、全部小学、部分高中、部分初中、部分小学）
        allList.primarySchool.map(item => {    //初中
            if (item.length == 0) return
            let school = item[0]
            chooseList.map(c => {
                if (school.schoolId == c.schoolId) {
                    if (arr.primarySchool && arr.primarySchool.c) {
                        arr.primarySchool.c.push(c)
                    } else {
                        arr.primarySchool = {}
                        arr.primarySchool.c = []
                        arr.primarySchool.c.push(c)
                    }
                }
            })
        })
        if (arr.primarySchool && arr.primarySchool.c) {
            if (arr.primarySchool.c.length == flatten(allList.primarySchool).length) {
                arr.primarySchool.name = "全部小学"
                arr.primarySchool.type = 1
            } else {
                arr.primarySchool.name = "部分小学"
                arr.primarySchool.type = 0
            }
        }
        allList.juniorSchool.map(item => {    //初中
            if (item.length == 0) return
            let school = item[0]
            chooseList.map(c => {
                if (school.schoolId == c.schoolId) {
                    if (arr.juniorSchool && arr.juniorSchool.c) {
                        arr.juniorSchool.c.push(c)
                    } else {
                        arr.juniorSchool = {}
                        arr.juniorSchool.c = []
                        arr.juniorSchool.c.push(c)
                    }
                }
            })
        })
        if (arr.juniorSchool && arr.juniorSchool.c) {
            if (arr.juniorSchool.c.length == flatten(allList.juniorSchool).length) {
                arr.juniorSchool.name = "全部初中"
                arr.juniorSchool.type = 1
            } else {
                arr.juniorSchool.name = "部分初中"
                arr.juniorSchool.type = 0
            }
        }
        allList.highSchool.map(item => {      //高中
            if (item.length == 0) return
            let school = item[0]
            chooseList.map(c => {
                if (school.schoolId == c.schoolId) {
                    if (arr.highSchool && arr.highSchool.c) {
                        arr.highSchool.c.push(c)
                    } else {
                        arr.highSchool = {}
                        arr.highSchool.c = []
                        arr.highSchool.c.push(c)
                    }
                }
            })
        })
        if (arr.highSchool && arr.highSchool.c) {
            if (arr.highSchool.c.length == flatten(allList.highSchool).length) {
                arr.highSchool.name = "全部高中"
                arr.highSchool.type = 1
            } else {
                arr.highSchool.name = "部分高中"
                arr.highSchool.type = 0
            }
        }
        let num = 0
        chooseList.map(item => {
            num += Number(item.userCount)
        })
        setAllNum(num)
        setSelectShowList(arr)
    }, [chooseList]);

    useEffect(() => {
        let checkCurList = [], status = 0
        console.log(`chooseList`, chooseList)
        if (level == 1) {
            showList.map((item, index) => {
                if (item.length == 0) return
                let school = item[0], arrLen = [], curlen = item.length
                // let hasCheck = false,hasUnCheck = false
                if (chooseType == 0) {
                    chooseList.map(t => {
                        // console.log()
                        if (t.schoolId == school.schoolId) {
                            arrLen.push(t)
                        }
                    })
                } else {
                    item.map(t => {
                        let flag = true
                        chooseList.map(c => {
                            if (c.identityId == t.identityId) {
                                flag = false
                            }
                        })
                        if (!flag) {
                            arrLen.push(t)
                        }
                    })
                }
                if (arrLen.length > 0 && arrLen.length < curlen) {
                    status = 0.5
                }
                if (arrLen.length == curlen) {
                    status = 1
                }
                if (arrLen.length == 0) {
                    status = 0
                }
                checkCurList.push(status)
            })
            let hc = false, huc = false
            let len = checkCurList.length, sum = 0
            // console.log(`checkCurList`, checkCurList)
            checkCurList.map(item => {
                sum += item
            })
            if (chooseList.length == 0) huc = true
            if (sum > 0 && sum < len) {
                setCheckStatus(0.5)
            }
            if (sum == len) {
                setCheckStatus(1)
            }
            if (sum == 0) {
                setCheckStatus(0)
            }
        } else if (level == 2) {
            let arr = []
            showList.map(item => {
                let flag = true
                chooseList.map(t => {
                    if (t.identityId == item.identityId) {
                        flag = false
                    }
                })
                if (!flag) {
                    arr.push(item)
                }
            })

            let len = arr.length
            if (len == 0) {
                setCheckStatus(0)
            }
            if (len > 0 && len < showList.length) {
                setCheckStatus(0.5)
            }
            if (len == showList.length) {
                setCheckStatus(1)
            }
        }

    }, [chooseList, showList])

    useEffect(() => {
        // console.log(props.visible,'props.visible')
        //学校所属阶段：小学类型(3, 8, 10)；初中类型(4, 8, 9, 10)；高中类型(5, 9, 10)；其他

        setIsVisiable(props.visible)
        setLevel(0)
        setChooseType(0)
        if (!props.visible) return
        setChooseList(props.chooseList ? props.chooseList : [])
        // console.log(`props.chooseList`, props.chooseList)
        let url = 'dev/api/commons/schools/receivers'
        let token = getQueryVariable('lg_tk')
        let arr = {
            "primarySchool": [],
            "juniorSchool": [],
            "highSchool": []
        }
        fetch.get({
            url, header: { Authorization: token }, securityLevel: 2
        }).then(res => {
            return res.json()
        }).then(json => {
            if (json.code == 200) {
                let list = json.data
                // let arr = []
                let newList = []
                list.map(item => {
                    if (item.length == 0) return
                    let newItem = item.filter(target => target.isPreset != "false")
                    // console.log(`item`, item)
                    newList.push(newItem)
                })

                // console.log(`list`, newList)

                list = newList
                setAllData(list)
                let schoolList = []
                list.map(item => {
                    if (item.length == 0) {
                        return
                    }
                    let school = item[0]
                    schoolList.push({
                        schoolName: school.schoolName,
                        schoolId: school.schoolId,
                        schoolLevel: school.schoolLevel,
                        children: item
                    })
                })

                setSchoolList(schoolList)

                list.map(item => {
                    if (item.length == 0) return
                    let school = item[0]

                    if (school.schoolLevel == 3 || school.schoolLevel == 8 || school.schoolLevel == 10) {
                        arr.primarySchool.push(item)
                    }
                    if (school.schoolLevel == 4 || school.schoolLevel == 8 || school.schoolLevel == 9 || school.schoolLevel == 10) {
                        arr.juniorSchool.push(item)
                    }
                    if (school.schoolLevel == 5 || school.schoolLevel == 9 || school.schoolLevel == 10) {
                        arr.highSchool.push(item)
                    }
                })
                setAllList(arr)
                // 
                let allListById = []
                if (arr.primarySchool.length > 0) {
                    arr.primarySchool[0].map(item => {
                        // allListById.push(item.identityCode)
                        if (!item.isPreset) return
                        allListById[item.identityCode] = [[], [], []] //[[高中],[初中],[小学]]
                    })
                }


                for (const key in allListById) {
                    if (Object.hasOwnProperty.call(allListById, key)) {
                        const element = allListById[key];   //[[],[],[]]  
                        element.map((item, index) => {   //index:1-高中、index-2:初中、index-3：小学 key:身份
                            let obj = {
                                1: 'highSchool', 2: 'juniorSchool', 3: "primarySchool"
                            }
                            arr[obj[index + 1]].map((t, i) => {
                                t.map((t1, i1) => {
                                    if (t1.identityCode == key) {
                                        item.push(t1)
                                    }
                                })
                            })
                        })
                    }
                }

                setAllListById(allListById)
                // console.log(`allListById`, allListById)
                if (!arr) return
                let idList = []
                if (
                    arr.primarySchool.length != 0
                ) {
                    arr.primarySchool[0].map(item => {
                        // console.log(`item.isPreset`, item.isPreset)
                        if (item.isPreset) {
                            idList.push(item)
                        }
                    })
                }

                // console.log(`idList`, idList)

                setIdList(idList)
            }
        })
    }, [props.visible])

    function changeShowList(level, type) {
        if(!allList){
            return
        }
        if (level == 1) {
            setShowList(allList[type])
            setLevel(1)
            setBreakList([type])
        }
        if (level == 2) {
            setPreList(showList)
            setShowList(type)
            setLevel(2)
            let arr = JSON.parse(JSON.stringify(breakList))
            if (type.length != 0) {
                arr.push(type[0].schoolName)
            }
            // console.log(`arr`, arr)
            setBreakList(arr)
        }
    }

    function changeShowList1(level, type, index) {
        if (level == 1) {
            setShowList(allListById[type.identityCode])
            setLevel(1)
            setBreakList([type.identityName])
        }
        if (level == 2) {
            setPreList(showList)
            setShowList(type)
            setLevel(2)
            let obj = {
                "0": "高中",
                "1": "初中",
                "2": "小学"
            }
            let arr = JSON.parse(JSON.stringify(breakList))
            arr.push(obj[index])
            // console.log(`arr`, arr)
            setBreakList(arr)
        }
    }

    function chooseItem(item, checkStatus) {
        if (Array.isArray(item)) { //父
            if (item.length == 0) return
            let parent = item[0]
            if (checkStatus == 0) {
                let arr = chooseList.concat(item)
                setChooseList(arr)
            } else {
                let arr = chooseList.filter(t => {
                    return t.schoolId != parent.schoolId
                })
                setChooseList(arr)
            }
        } else {
            // console.log(item,checkStatus)         //子
            if (checkStatus == 0) {
                let arr = JSON.parse(JSON.stringify(chooseList))
                // let arr = chooseList
                arr.push(item)
                // console.log(arr,'arr')
                setChooseList(arr)
                // console.log(chooseList,'chooseList')
            } else {
                let arr = chooseList.filter(t => {
                    return t.identityId != item.identityId
                })
                // console.log(arr,'arr')
                setChooseList(arr)
            }
        }
    }

    function chooseItem1(item, checkStatus) {
        if (Array.isArray(item)) { //父
            if (item.length == 0) return
            let parent = item[0]
            if (checkStatus == 0) {
                let arr = chooseList.concat(item)
                setChooseList(arr)
            } else {
                let arr = []
                chooseList.map(t => {
                    let flag = true
                    item.map(c => {
                        if (t.identityId == c.identityId) {
                            flag = false
                        }
                    })
                    if (flag) {
                        arr.push(t)
                    }
                })
                // console.log(arr,'arr')
                setChooseList(arr)
            }
        } else {         //子
            if (checkStatus == 0) {
                let arr = JSON.parse(JSON.stringify(chooseList))
                arr.push(item)
                setChooseList(arr)
            } else {
                let arr = chooseList.filter(t => {
                    return t.identityId != item.identityId
                })
                setChooseList(arr)
            }
        }
    }

    function chooseAll() {
        if (level == 1) {
            if (checkStatus == 0) {
                // console.log(showList,'showList')
                let arr = []
                showList.map(item => {
                    item.map(t => {
                        arr.push(t)
                    })
                })
                setChooseList(chooseList.concat(arr))
            } else if (checkStatus == 1 || checkStatus == 0.5) {
                // console.log(showList,'showList')
                let cl = Object.assign([], chooseList)
                let sl = Object.assign([], showList)
                // console.log(`sl`, sl)
                cl = cl.filter(item => {
                    let flag = true
                    sl.map(t => {
                        t.map(c => {
                            if (c.identityId == item.identityId) {
                                flag = false
                            }
                        })

                    })
                    return flag
                })
                setChooseList(cl)
            }
        } else if (level == 2) {
            if (checkStatus == 0) {
                setChooseList(chooseList.concat(showList))
            } else if (checkStatus == 1 || checkStatus == 0.5) {
                let arr = []
                chooseList.map(t => {
                    let flag = false
                    showList.map(item => {
                        if (item.identityId == t.identityId) {
                            flag = true
                        }
                    })
                    if (!flag) {
                        arr.push(t)
                    }
                })
                setChooseList(arr)
            }
        }
    }

    function backLevel() {
        if (level == 0) return
        setLevel(level - 1)

        if (level == 2) {
            setShowList(preList)
            let arr = JSON.parse(JSON.stringify(breakList))
            arr.pop()
            setBreakList(arr)
        }
    }

    function deleteChoose(item, index) {
        let list = Object.assign([], chooseList)
        list.splice(index, 1)
        setChooseList(list)
    }

    // const [submit, setSubmit] = useState(false);

    // useEffect(() => {
    //     // console.log(`chooseList`, chooseList)
    //     if(submit){
    //         if(chooseList.length > 0){
    //             props.getSelect(chooseList)
    //             props.onClose()
    //         }else {

    //         }
    //     }

    // }, [submit]);

    function sure() {
        if (chooseList.length == 0) {

        } else {
            props.getSelect(chooseList, selectShowList)
            props.onClose()
        }
    }

    const [breakList, setBreakList] = useState([]);

    const toTheFirstLevel = (item, index) => {
        if (index == 0 && level == 2) {   //在最后一级并且点击了第一层级，直接回到第一页
            setLevel(0)
        }
    }

    const [searchList, setSearchList] = useState([]);
    const [searchValue, setSearchValue] = useState("");
    const onSearch = (e) => {
        // console.log(`object`, e.target.value)
        setSearchValue(e.target.value)
    }

    useEffect(() => {
        if (searchValue == "") {
            setSearchList([])
            return
        }
        // console.log(`allList`, allList)
        let list = []

        schoolList.map(item => {
            if (item.schoolName.indexOf(searchValue) > -1) {
                let children = [].concat(item.children)
                children.unshift({
                    identityName: "全部",
                    schoolId: item.schoolId,
                    schoolLevel: item.schoolLevel,
                    schoolName: item.schoolName,
                    children: item.children
                })
                list.push(...children)
            }
        })

        setSearchList(list)

    }, [searchValue]);

    const chooseSearch = (item) => {
        let cl = [].concat(chooseList)
        if (item.identityName == "全部") {
            item.children.map(target => {
                let isExit = false
                cl.map(c => {
                    if (c.identityId == target.identityId) {
                        isExit = true
                    }
                })
                if (!isExit) {
                    cl.push(target)
                }
            })
        } else {
            let isExit = false
            cl.map(c => {
                if (c.identityId == item.identityId) {
                    isExit = true
                }
            })
            if (!isExit) {
                cl.push(item)
            } else {
                message.warn('已选择该对象')
            }
        }
        setSearchValue("")
        setChooseList(cl)
    }

    return (
        <Modal
            visible={isVisiable}
            onCancel={props.onClose}
            type="1"
            title="选择发布对象"
            width="900px"
            bodyStyle={{
                padding: 0,
                height: 536
            }}
            className="select_user_modal"
            footer={null}
            zIndex={2000}
        >
            <div style={{ height: '100%' }} className="clear">
                <div className="select_right">
                    <Scrollbars
                        autoHeightMax={450}
                        renderThumbVertical={props => <div {...props} className="thumb-vertical" />}
                    >
                        {
                            chooseList.map((item, index) => {
                                return (
                                    <div key={index} className="select_item">
                                        <span className="tabName ellipsis" title={item.schoolName + "-" + item.identityName}
                                        >{item.schoolName + "-" + item.identityName}</span>
                                        <span className="deleteIcon" onClick={() => deleteChoose(item, index)}></span>
                                    </div>
                                )
                            })
                        }
                        <div className="searchContent">

                            <input className="searchInput" value={searchValue} onChange={onSearch} placeholder="按学校搜索..." />
                            <div className="searchList">
                                <Scrollbars
                                    autoHeight
                                    autoHeightMax={210}
                                    renderThumbVertical={props => <div {...props} className="thumb-vertical" />}
                                >
                                    {/* <div className="searchList"> */}
                                    {
                                        searchList.map(item => {
                                            return (
                                                <div onClick={() => chooseSearch(item)} title={item.identityName + "(" + item.schoolName + ")"} className="searchItem ellipsis">
                                                    {item.identityName}({item.schoolName})
                                                </div>
                                            )
                                        })
                                    }
                                    {
                                        (searchValue !== "" && searchList.length == 0) ?
                                            <div className='noResult'>
                                                没有匹配到任何结果
                                            </div> : null
                                    }

                                    {/* </div> */}
                                </Scrollbars>
                            </div>
                        </div>
                    </Scrollbars>
                </div>
                <div className="select_left">
                    <Scrollbars
                        autoHeight
                        autoHeightMax={520}
                        renderThumbVertical={props => <div {...props} className="thumb-vertical" />}
                    >
                        {
                            level != 0 ?
                                <div className="chooseTypeBox">
                                    <i onClick={backLevel} className="chooseBack"></i>
                                    <div className="breadList">
                                        {
                                            breakList.map((item, index) => {
                                                let obj = {
                                                    "highSchool": "高中",
                                                    "juniorSchool": "初中",
                                                    "primarySchool": "小学"
                                                }
                                                let name = obj[item] ? obj[item] : item
                                                let len = breakList.length
                                                return (
                                                    <span style={{
                                                        color: len == 2 && index == 0 ? "#0099ff" : ""
                                                    }} onClick={() => toTheFirstLevel(item, index)}>{len == 2 && index == 1 ? "/" : ""}

                                                        {name}
                                                    </span>
                                                )
                                            })
                                        }
                                    </div>
                                </div> : null
                        }
                        {
                            level == 0 ? <div className="chooseTypeBox">
                                <span className={!chooseType ? "chooseTypeBtn active" : "chooseTypeBtn"} onClick={() => setChooseType(0)}>
                                    按学校
                                </span>
                                <span className={!chooseType ? "chooseTypeBtn" : "chooseTypeBtn active"} onClick={() => setChooseType(1)}>
                                    按角色
                                </span>
                            </div> : null
                        }
                        {
                            chooseType == 0 ? //0 按学校  1按角色
                                <div>
                                    {
                                        level == 0 ? <div className="chooseLevel0">
                                            <p onClick={() => changeShowList(1, "highSchool")}><i className={"icon icon_highSchool"}></i>高中</p>
                                            <p onClick={() => changeShowList(1, "juniorSchool")}><i className={"icon icon_juniorSchool"}></i>初中</p>
                                            <p onClick={() => changeShowList(1, "primarySchool")}><i className={"icon icon_primarySchool"}></i>小学</p>
                                        </div> : null
                                    }
                                    {
                                        level == 1 ? <div className="chooseLevel1">
                                            <p>
                                                <span onClick={() => chooseAll()} className={"checkIcon-" + checkStatus * 10}></span>
                                                <span>全选</span>
                                            </p>
                                            {
                                                showList.map((item, index) => {
                                                    // console.log(item,'item')
                                                    if (item.length == 0) return
                                                    let school = item[0]
                                                    let checkStatus = 0
                                                    let len = item.length, arr = []
                                                    let num = 0
                                                    // console.log(chooseList,'chooseList')
                                                    chooseList.map(t => {
                                                        if (t.schoolId == school.schoolId) {
                                                            arr.push(1)
                                                        }
                                                    })
                                                    item.map(t => {
                                                        if (t.isPreset == "true") {
                                                            num += Number(t.userCount)
                                                        }
                                                    })
                                                    // console.log(`num`, num)
                                                    if (len == arr.length) {
                                                        checkStatus = 1
                                                    } else if (arr.length == 0) {
                                                        checkStatus = 0
                                                    } else {
                                                        checkStatus = 0.5
                                                    }
                                                    // checkCurList[index] = checkStatus
                                                    return (
                                                        <p key={school.schoolId}>
                                                            <span className={"checkIcon-" + checkStatus * 10} onClick={() => chooseItem(item, checkStatus)}></span>
                                                            <span onClick={() => changeShowList(2, item)} >{school.schoolName} ({school.totalCount}人) </span>
                                                            <span onClick={() => changeShowList(2, item)} className="right nextBtn" style={{ marginRight: 20 }}><span style={{ marginRight: 8 }}>|</span><i className="nextIcon"></i> 下级</span>
                                                        </p>
                                                    )
                                                })
                                            }
                                        </div> : null
                                    }
                                    {
                                        level == 2 ? <div className="chooseLevel2">
                                            <p>
                                                <span onClick={() => chooseAll()} className={"checkIcon-" + checkStatus * 10}></span>
                                                <span>全选</span>
                                            </p>
                                            {
                                                showList.map(item => {
                                                    let checkStatus = 0
                                                    // console.log(item,'item')
                                                    // console.log(chooseList,'chooseList')
                                                    if (item.isPreset == "false") return
                                                    chooseList.forEach(t => {
                                                        if (t.identityId == item.identityId) {
                                                            checkStatus = 1
                                                        }
                                                    })
                                                    // console.log(checkStatus,'checkStatus') 
                                                    return (
                                                        <p key={item.identityId}>
                                                            <span className={"checkIcon-" + checkStatus * 10} onClick={() => chooseItem(item, checkStatus)}></span>
                                                            {item.identityName}  ({item.userCount}人)
                                                        </p>
                                                    )
                                                })
                                            }
                                        </div> : null
                                    }
                                </div>
                                :
                                <div>
                                    {
                                        level == 0 ? <div className="chooseLevel0">
                                            {
                                                idList.map(item => {
                                                    if (item.isPreset == "false") return
                                                    console.log(`item.identityCode`, item.identityCode)
                                                    return (
                                                        <p onClick={() => changeShowList1(1, item)} key={item.identityCode}>
                                                            <i className={"icon icon_" + (item.identityCode)}></i>
                                                            {item.identityName}
                                                        </p>
                                                    )
                                                })
                                            }
                                        </div> : null
                                    }
                                    {
                                        level == 1 ? <div className="chooseLevel1">
                                            <p>
                                                <span onClick={() => chooseAll()} className={"checkIcon-" + checkStatus * 10}></span>
                                                <span>全选</span>
                                            </p>
                                            {
                                                showList.map((item, index) => {
                                                    // console.log(item,'item')
                                                    // console.log(`showList`, showList)
                                                    if (item.length == 0) return
                                                    let school = item[0]
                                                    let checkStatus = 0
                                                    let len = item.length, arr = []
                                                    let obj = {
                                                        "0": "高中",
                                                        "1": "初中",
                                                        "2": "小学"
                                                    }
                                                    let num = 0
                                                    item.map(t => {
                                                        // console.log(`item`, item)
                                                        let flag = true
                                                        chooseList.map(c => {
                                                            if (c.identityId == t.identityId) {
                                                                flag = false
                                                            }
                                                        })
                                                        if (!flag) {
                                                            arr.push(t)
                                                        }
                                                    })
                                                    if (len == arr.length) {
                                                        checkStatus = 1
                                                    } else if (arr.length == 0) {
                                                        checkStatus = 0
                                                    } else {
                                                        checkStatus = 0.5
                                                    }
                                                    item.map(t => {
                                                        // console.log(`t`, t)
                                                        num += Number(t.userCount)
                                                    })
                                                    // console.log(`num`, num)
                                                    return (
                                                        <p key={index}>
                                                            <span className={"checkIcon-" + checkStatus * 10} onClick={() => chooseItem1(item, checkStatus)}></span>
                                                            <span onClick={() => changeShowList1(2, item, index)} >{obj[index]} ({num}人) </span>
                                                            <span onClick={() => changeShowList1(2, item, index)} className="right nextBtn" style={{ marginRight: 20 }}><span style={{ marginRight: 8 }}>|</span><i className="nextIcon"></i> 下级</span>
                                                        </p>
                                                    )
                                                })
                                            }
                                        </div> : null
                                    }
                                    {
                                        level == 2 ? <div className="chooseLevel2">
                                            <p>
                                                <span onClick={() => chooseAll()} className={"checkIcon-" + checkStatus * 10}></span>
                                                <span>全选</span>
                                            </p>
                                            {
                                                showList.map(item => {
                                                    let checkStatus = 0
                                                    // console.log(item,'item')
                                                    // console.log(chooseList,'chooseList')
                                                    chooseList.forEach(t => {
                                                        if (t.identityId == item.identityId) {
                                                            checkStatus = 1
                                                        }
                                                    })
                                                    // console.log(`item`, item)
                                                    // console.log(checkStatus,'checkStatus') 
                                                    return (
                                                        <p key={item.identityId}>
                                                            <span className={"checkIcon-" + checkStatus * 10} onClick={() => chooseItem1(item, checkStatus)}></span>
                                                            {item.schoolName} ({item.userCount})人
                                                        </p>
                                                    )
                                                })
                                            }
                                        </div> : null
                                    }
                                </div>

                        }


                    </Scrollbars>
                </div>
            </div>
            <div className="select_footer">
                {/* <Button color="blue" onClick={sure} >确定(已选{allNum}人) </Button> */}
                {/* <Button color="blue" onClick={sure} >确定 </Button> */}
                {/* <Button color="red" style={{marginLeft: 12}} onClick={props.onClose}>取消 </Button> */}
                <span className='sureBtn' onClick={sure}>确定</span>
                <span className='closeBtn' onClick={props.onClose}>取消</span>
            </div>
        </Modal>
    )
}

export default SelectUser